package com.ttx.pattern.example.visitor.after;

/**
 * @author TimFruit
 * @date 19-6-2 上午1:38
 */
public class ConcreteVisitor2 implements Visitor {
    @Override
    public void visit(Element element) {
        if(element instanceof ConcreteElement){
            ConcreteElement concreteElement=(ConcreteElement) element;

            // 只关注 Value
            int total=0;
            for(int value: concreteElement.getValues()){
                total+=value;
            }

            System.out.println("concreteVisitor2 访问value之和: "+total);


        }else {
            throw new RuntimeException("具体元素不能被识别访问");
        }
    }
}
